summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-clone.txt2
-rw-r--r--Documentation/git-pack-objects.txt8
-rw-r--r--Documentation/git-push.txt6
-rw-r--r--Documentation/git-rebase.txt9
-rw-r--r--Documentation/git-send-email.txt35
-rw-r--r--Makefile2
-rw-r--r--builtin-apply.c3
-rw-r--r--builtin-fetch--tool.c21
-rw-r--r--builtin-push.c2
-rw-r--r--builtin-tag.c18
-rw-r--r--builtin-update-ref.c9
-rwxr-xr-xcontrib/fast-import/git-p4342
-rwxr-xr-xcontrib/workdir/git-new-workdir6
-rw-r--r--diff.c21
-rwxr-xr-xgit-cvsimport.perl2
-rwxr-xr-xgit-rebase.sh6
-rwxr-xr-xgit-send-email.perl101
-rwxr-xr-xgit-svn.perl25
-rwxr-xr-xgit-svnimport.perl2
-rw-r--r--refs.c27
-rw-r--r--refs.h6
-rw-r--r--send-pack.c12
-rwxr-xr-xt/t1400-update-ref.sh2
-rwxr-xr-xt/t4123-apply-shrink.sh58
-rwxr-xr-xt/t7004-tag.sh7
-rwxr-xr-xt/t7400-submodule-basic.sh4
26 files changed, 515 insertions, 221 deletions
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 227f092..253f4f0 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -68,7 +68,7 @@ OPTIONS
automatically setup .git/objects/info/alternates to
obtain objects from the reference repository. Using
an already existing repository as an alternate will
- require less objects to be copied from the repository
+ require fewer objects to be copied from the repository
being cloned, reducing network and local storage costs.
--quiet::
diff --git a/Documentation/git-pack-objects.txt b/Documentation/git-pack-objects.txt
index 6f17cff..f8a0be3 100644
--- a/Documentation/git-pack-objects.txt
+++ b/Documentation/git-pack-objects.txt
@@ -155,12 +155,8 @@ base-name::
generated pack. If not specified, pack compression level is
determined first by pack.compression, then by core.compression,
and defaults to -1, the zlib default, if neither is set.
- Data copied from loose objects will be recompressed
- if core.legacyheaders was true when they were created or if
- the loose compression level (see core.loosecompression and
- core.compression) is now a different value than the pack
- compression level. Add --no-reuse-object if you want to force
- a uniform compression level on all data no matter the source.
+ Add \--no-reuse-object if you want to force a uniform compression
+ level on all data no matter the source.
--delta-base-offset::
A packed archive can express base object of a delta as
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 0dd9caf..7b8e075 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -117,6 +117,12 @@ git push origin master:satellite/master::
the ref that matches `satellite/master` (most likely, it would
be `refs/remotes/satellite/master`) in `origin` repository with it.
+git push origin master:refs/heads/experimental::
+ Create the branch `experimental` in the `origin` repository
+ by copying the current `master` branch. This form is usually
+ needed to create a new branch in the remote repository as
+ there is no `experimental` branch to match.
+
Author
------
Written by Junio C Hamano <junkio@cox.net>, later rewritten in C
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 61b1810..0858fa8 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -8,8 +8,9 @@ git-rebase - Forward-port local commits to the updated upstream head
SYNOPSIS
--------
[verse]
-'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge] [-C<n>]
- [-p | --preserve-merges] [--onto <newbase>] <upstream> [<branch>]
+'git-rebase' [-i | --interactive] [-v | --verbose] [-m | --merge]
+ [-C<n>] [ --whitespace=<option>] [-p | --preserve-merges]
+ [--onto <newbase>] <upstream> [<branch>]
'git-rebase' --continue | --skip | --abort
DESCRIPTION
@@ -209,6 +210,10 @@ OPTIONS
context exist they all must match. By default no context is
ever ignored.
+--whitespace=<nowarn|warn|error|error-all|strip>::
+ This flag is passed to the `git-apply` program
+ (see gitlink:git-apply[1]) that applies the patch.
+
-i, \--interactive::
Make a list of the commits which are about to be rebased. Let the
user edit that list before rebasing. This mode can also be used to
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 16bfd7b..1ec61af 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -75,6 +75,12 @@ The --cc option must be repeated for each user you want on the cc list.
Make git-send-email less verbose. One line per email should be
all that is output.
+--identity::
+ A configuration identity. When given, causes values in the
+ 'sendemail.<identity>' subsection to take precedence over
+ values in the 'sendemail' section. The default identity is
+ the value of 'sendemail.identity'.
+
--smtp-server::
If set, specifies the outgoing SMTP server to use (e.g.
`smtp.example.com` or a raw IP address). Alternatively it can
@@ -85,6 +91,17 @@ The --cc option must be repeated for each user you want on the cc list.
`/usr/lib/sendmail` if such program is available, or
`localhost` otherwise.
+--smtp-user, --smtp-pass::
+ Username and password for SMTP-AUTH. Defaults are the values of
+ the configuration values 'sendemail.smtpuser' and
+ 'sendemail.smtppass', but see also 'sendemail.identity'.
+ If not set, authentication is not attempted.
+
+--smtp-ssl::
+ If set, connects to the SMTP server using SSL.
+ Default is the value of the 'sendemail.smtpssl' configuration value;
+ if that is unspecified, does not use SSL.
+
--subject::
Specify the initial subject of the email thread.
Only necessary if --compose is also set. If --compose
@@ -122,6 +139,13 @@ The --to option must be repeated for each user you want on the to list.
CONFIGURATION
-------------
+sendemail.identity::
+ The default configuration identity. When specified,
+ 'sendemail.<identity>.<item>' will have higher precedence than
+ 'sendemail.<item>'. This is useful to declare multiple SMTP
+ identities and to hoist sensitive authentication information
+ out of the repository and into the global configuation file.
+
sendemail.aliasesfile::
To avoid typing long email addresses, point this to one or more
email aliases files. You must also supply 'sendemail.aliasfiletype'.
@@ -141,7 +165,16 @@ sendemail.chainreplyto::
parameter.
sendemail.smtpserver::
- Default smtp server to use.
+ Default SMTP server to use.
+
+sendemail.smtpuser::
+ Default SMTP-AUTH username.
+
+sendemail.smtppass::
+ Default SMTP-AUTH password.
+
+sendemail.smtpssl::
+ Boolean value specifying the default to the '--smtp-ssl' parameter.
Author
------
diff --git a/Makefile b/Makefile
index c68b530..61053ae 100644
--- a/Makefile
+++ b/Makefile
@@ -283,7 +283,7 @@ LIB_FILE=libgit.a
XDIFF_LIB=xdiff/lib.a
LIB_H = \
- archive.h blob.h cache.h commit.h csum-file.h delta.h grep.h \
+ archive.h blob.h cache.h cache-tree.h commit.h csum-file.h delta.h grep.h \
diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
diff --git a/builtin-apply.c b/builtin-apply.c
index 25b1447..976ec77 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -1514,7 +1514,8 @@ static int find_offset(const char *buf, unsigned long size, const char *fragment
}
/* Exact line number? */
- if (!memcmp(buf + start, fragment, fragsize))
+ if ((start + fragsize <= size) &&
+ !memcmp(buf + start, fragment, fragsize))
return start;
/*
diff --git a/builtin-fetch--tool.c b/builtin-fetch--tool.c
index e2f8ede..24c7e6f 100644
--- a/builtin-fetch--tool.c
+++ b/builtin-fetch--tool.c
@@ -31,24 +31,19 @@ static void show_new(enum object_type type, unsigned char *sha1_new)
find_unique_abbrev(sha1_new, DEFAULT_ABBREV));
}
-static int update_ref(const char *action,
+static int update_ref_env(const char *action,
const char *refname,
unsigned char *sha1,
unsigned char *oldval)
{
char msg[1024];
char *rla = getenv("GIT_REFLOG_ACTION");
- static struct ref_lock *lock;
if (!rla)
rla = "(reflog update)";
- snprintf(msg, sizeof(msg), "%s: %s", rla, action);
- lock = lock_any_ref_for_update(refname, oldval, 0);
- if (!lock)
- return 1;
- if (write_ref_sha1(lock, sha1, msg) < 0)
- return 1;
- return 0;
+ if (snprintf(msg, sizeof(msg), "%s: %s", rla, action) >= sizeof(msg))
+ warning("reflog message too long: %.*s...", 50, msg);
+ return update_ref(msg, refname, sha1, oldval, 0, QUIET_ON_ERR);
}
static int update_local_ref(const char *name,
@@ -88,7 +83,7 @@ static int update_local_ref(const char *name,
fprintf(stderr, "* %s: storing %s\n",
name, note);
show_new(type, sha1_new);
- return update_ref(msg, name, sha1_new, NULL);
+ return update_ref_env(msg, name, sha1_new, NULL);
}
if (!hashcmp(sha1_old, sha1_new)) {
@@ -102,7 +97,7 @@ static int update_local_ref(const char *name,
if (!strncmp(name, "refs/tags/", 10)) {
fprintf(stderr, "* %s: updating with %s\n", name, note);
show_new(type, sha1_new);
- return update_ref("updating tag", name, sha1_new, NULL);
+ return update_ref_env("updating tag", name, sha1_new, NULL);
}
current = lookup_commit_reference(sha1_old);
@@ -117,7 +112,7 @@ static int update_local_ref(const char *name,
fprintf(stderr, "* %s: fast forward to %s\n",
name, note);
fprintf(stderr, " old..new: %s..%s\n", oldh, newh);
- return update_ref("fast forward", name, sha1_new, sha1_old);
+ return update_ref_env("fast forward", name, sha1_new, sha1_old);
}
if (!force) {
fprintf(stderr,
@@ -131,7 +126,7 @@ static int update_local_ref(const char *name,
"* %s: forcing update to non-fast forward %s\n",
name, note);
fprintf(stderr, " old...new: %s...%s\n", oldh, newh);
- return update_ref("forced-update", name, sha1_new, sha1_old);
+ return update_ref_env("forced-update", name, sha1_new, sha1_old);
}
static int append_fetch_head(FILE *fp,
diff --git a/builtin-push.c b/builtin-push.c
index 2612f07..88c5024 100644
--- a/builtin-push.c
+++ b/builtin-push.c
@@ -9,7 +9,7 @@
static const char push_usage[] = "git-push [--all] [--tags] [--receive-pack=<git-receive-pack>] [--repo=all] [-f | --force] [-v] [<repository> <refspec>...]";
-static int all, force, thin = 1, verbose;
+static int all, force, thin, verbose;
static const char *receivepack;
static const char **refspec;
diff --git a/builtin-tag.c b/builtin-tag.c
index 348919c..3a9d2ee 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -200,6 +200,10 @@ static ssize_t do_sign(char *buffer, size_t size, size_t max)
bracket[1] = '\0';
}
+ /* When the username signingkey is bad, program could be terminated
+ * because gpg exits without reading and then write gets SIGPIPE. */
+ signal(SIGPIPE, SIG_IGN);
+
memset(&gpg, 0, sizeof(gpg));
gpg.argv = args;
gpg.in = -1;
@@ -212,12 +216,17 @@ static ssize_t do_sign(char *buffer, size_t size, size_t max)
if (start_command(&gpg))
return error("could not run gpg.");
- write_or_die(gpg.in, buffer, size);
+ if (write_in_full(gpg.in, buffer, size) != size) {
+ close(gpg.in);
+ finish_command(&gpg);
+ return error("gpg did not accept the tag data");
+ }
close(gpg.in);
gpg.close_in = 0;
len = read_in_full(gpg.out, buffer + size, max - size);
- finish_command(&gpg);
+ if (finish_command(&gpg) || !len || len < 0)
+ return error("gpg failed to sign the tag");
if (len == max - size)
return error("could not read the entire signature from gpg.");
@@ -310,9 +319,10 @@ static void create_tag(const unsigned char *object, const char *tag,
size += header_len;
if (sign) {
- size = do_sign(buffer, size, max_size);
- if (size < 0)
+ ssize_t r = do_sign(buffer, size, max_size);
+ if (r < 0)
die("unable to sign the tag");
+ size = r;
}
if (write_sha1_file(buffer, size, tag_type, result) < 0)
diff --git a/builtin-update-ref.c b/builtin-update-ref.c
index 8339cf1..fe1f74c 100644
--- a/builtin-update-ref.c
+++ b/builtin-update-ref.c
@@ -8,7 +8,6 @@ static const char git_update_ref_usage[] =
int cmd_update_ref(int argc, const char **argv, const char *prefix)
{
const char *refname=NULL, *value=NULL, *oldval=NULL, *msg=NULL;
- struct ref_lock *lock;
unsigned char sha1[20], oldsha1[20];
int i, delete, ref_flags;
@@ -62,10 +61,6 @@ int cmd_update_ref(int argc, const char **argv, const char *prefix)
if (oldval && *oldval && get_sha1(oldval, oldsha1))
die("%s: not a valid old SHA1", oldval);
- lock = lock_any_ref_for_update(refname, oldval ? oldsha1 : NULL, ref_flags);
- if (!lock)
- die("%s: cannot lock the ref", refname);
- if (write_ref_sha1(lock, sha1, msg) < 0)
- die("%s: cannot update the ref", refname);
- return 0;
+ return update_ref(msg, refname, sha1, oldval ? oldsha1 : NULL,
+ ref_flags, DIE_ON_ERR);
}
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 55778c5..adaaae6 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -281,6 +281,19 @@ def createOrUpdateBranchesFromOrigin(localRefPrefix = "refs/remotes/p4/", silent
def originP4BranchesExist():
return gitBranchExists("origin") or gitBranchExists("origin/p4") or gitBranchExists("origin/p4/master")
+def p4ChangesForPaths(depotPaths, changeRange):
+ assert depotPaths
+ output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, changeRange)
+ for p in depotPaths]))
+
+ changes = []
+ for line in output:
+ changeNum = line.split(" ")[1]
+ changes.append(int(changeNum))
+
+ changes.sort()
+ return changes
+
class Command:
def __init__(self):
self.usage = "usage: %prog [options]"
@@ -664,9 +677,8 @@ class P4Submit(Command):
f.close();
os.chdir(self.clientPath)
- response = raw_input("Do you want to sync %s with p4 sync? [y]es/[n]o " % self.clientPath)
- if response == "y" or response == "yes":
- system("p4 sync ...")
+ print "Syncronizing p4 checkout..."
+ system("p4 sync ...")
if self.reset:
self.firstTime = True
@@ -705,10 +717,14 @@ class P4Submit(Command):
else:
print "All changes applied!"
os.chdir(self.oldWorkingDirectory)
- response = raw_input("Do you want to sync from Perforce now using git-p4 rebase? [y]es/[n]o ")
+
+ sync = P4Sync()
+ sync.run([])
+
+ response = raw_input("Do you want to rebase current HEAD from Perforce now using git-p4 rebase? [y]es/[n]o ")
if response == "y" or response == "yes":
rebase = P4Rebase()
- rebase.run([])
+ rebase.rebase()
os.remove(self.configFile)
return True
@@ -1102,6 +1118,186 @@ class P4Sync(Command):
self.keepRepoPath = (d.has_key('options')
and ('keepRepoPath' in d['options']))
+ def gitRefForBranch(self, branch):
+ if branch == "main":
+ return self.refPrefix + "master"
+
+ if len(branch) <= 0:
+ return branch
+
+ return self.refPrefix + self.projectName + branch
+
+ def gitCommitByP4Change(self, ref, change):
+ if self.verbose:
+ print "looking in ref " + ref + " for change %s using bisect..." % change
+
+ earliestCommit = ""
+ latestCommit = parseRevision(ref)
+
+ while True:
+ if self.verbose:
+ print "trying: earliest %s latest %s" % (earliestCommit, latestCommit)
+ next = read_pipe("git rev-list --bisect %s %s" % (latestCommit, earliestCommit)).strip()
+ if len(next) == 0:
+ if self.verbose:
+ print "argh"
+ return ""
+ log = extractLogMessageFromGitCommit(next)
+ settings = extractSettingsGitLog(log)
+ currentChange = int(settings['change'])
+ if self.verbose:
+ print "current change %s" % currentChange
+
+ if currentChange == change:
+ if self.verbose:
+ print "found %s" % next
+ return next
+
+ if currentChange < change:
+ earliestCommit = "^%s" % next
+ else:
+ latestCommit = "%s" % next
+
+ return ""
+
+ def importNewBranch(self, branch, maxChange):
+ # make fast-import flush all changes to disk and update the refs using the checkpoint
+ # command so that we can try to find the branch parent in the git history
+ self.gitStream.write("checkpoint\n\n");
+ self.gitStream.flush();
+ branchPrefix = self.depotPaths[0] + branch + "/"
+ range = "@1,%s" % maxChange
+ #print "prefix" + branchPrefix
+ changes = p4ChangesForPaths([branchPrefix], range)
+ if len(changes) <= 0:
+ return False
+ firstChange = changes[0]
+ #print "first change in branch: %s" % firstChange
+ sourceBranch = self.knownBranches[branch]
+ sourceDepotPath = self.depotPaths[0] + sourceBranch
+ sourceRef = self.gitRefForBranch(sourceBranch)
+ #print "source " + sourceBranch
+
+ branchParentChange = int(p4Cmd("changes -m 1 %s...@1,%s" % (sourceDepotPath, firstChange))["change"])
+ #print "branch parent: %s" % branchParentChange
+ gitParent = self.gitCommitByP4Change(sourceRef, branchParentChange)
+ if len(gitParent) > 0:
+ self.initialParents[self.gitRefForBranch(branch)] = gitParent
+ #print "parent git commit: %s" % gitParent
+
+ self.importChanges(changes)
+ return True
+
+ def importChanges(self, changes):
+ cnt = 1
+ for change in changes:
+ description = p4Cmd("describe %s" % change)
+ self.updateOptionDict(description)
+
+ if not self.silent:
+ sys.stdout.write("\rImporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
+ sys.stdout.flush()
+ cnt = cnt + 1
+
+ try:
+ if self.detectBranches:
+ branches = self.splitFilesIntoBranches(description)
+ for branch in branches.keys():
+ ## HACK --hwn
+ branchPrefix = self.depotPaths[0] + branch + "/"
+
+ parent = ""
+
+ filesForCommit = branches[branch]
+
+ if self.verbose:
+ print "branch is %s" % branch
+
+ self.updatedBranches.add(branch)
+
+ if branch not in self.createdBranches:
+ self.createdBranches.add(branch)
+ parent = self.knownBranches[branch]
+ if parent == branch:
+ parent = ""
+ else:
+ fullBranch = self.projectName + branch
+ if fullBranch not in self.p4BranchesInGit:
+ if not self.silent:
+ print("\n Importing new branch %s" % fullBranch);
+ if self.importNewBranch(branch, change - 1):
+ parent = ""
+ self.p4BranchesInGit.append(fullBranch)
+ if not self.silent:
+ print("\n Resuming with change %s" % change);
+
+ if self.verbose:
+ print "parent determined through known branches: %s" % parent
+
+ branch = self.gitRefForBranch(branch)
+ parent = self.gitRefForBranch(parent)
+
+ if self.verbose:
+ print "looking for initial parent for %s; current parent is %s" % (branch, parent)
+
+ if len(parent) == 0 and branch in self.initialParents:
+ parent = self.initialParents[branch]
+ del self.initialParents[branch]
+
+ self.commit(description, filesForCommit, branch, [branchPrefix], parent)
+ else:
+ files = self.extractFilesFromCommit(description)
+ self.commit(description, files, self.branch, self.depotPaths,
+ self.initialParent)
+ self.initialParent = ""
+ except IOError:
+ print self.gitError.read()
+ sys.exit(1)
+
+ def importHeadRevision(self, revision):
+ print "Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch)
+
+ details = { "user" : "git perforce import user", "time" : int(time.time()) }
+ details["desc"] = ("Initial import of %s from the state at revision %s"
+ % (' '.join(self.depotPaths), revision))
+ details["change"] = revision
+ newestRevision = 0
+
+ fileCnt = 0
+ for info in p4CmdList("files "
+ + ' '.join(["%s...%s"
+ % (p, revision)
+ for p in self.depotPaths])):
+
+ if info['code'] == 'error':
+ sys.stderr.write("p4 returned an error: %s\n"
+ % info['data'])
+ sys.exit(1)
+
+
+ change = int(info["change"])
+ if change > newestRevision:
+ newestRevision = change
+
+ if info["action"] == "delete":
+ # don't increase the file cnt, otherwise details["depotFile123"] will have gaps!
+ #fileCnt = fileCnt + 1
+ continue
+
+ for prop in ["depotFile", "rev", "action", "type" ]:
+ details["%s%s" % (prop, fileCnt)] = info[prop]
+
+ fileCnt = fileCnt + 1
+
+ details["change"] = newestRevision
+ self.updateOptionDict(details)
+ try:
+ self.commit(details, self.extractFilesFromCommit(details), self.branch, self.depotPaths)
+ except IOError:
+ print "IO error with git fast-import. Is your git version recent enough?"
+ print self.gitError.read()
+
+
def run(self, args):
self.depotPaths = []
self.changeRange = ""
@@ -1199,7 +1395,7 @@ class P4Sync(Command):
self.depotPaths = sorted(args)
- self.revision = ""
+ revision = ""
self.users = {}
newPaths = []
@@ -1210,15 +1406,15 @@ class P4Sync(Command):
if self.changeRange == "@all":
self.changeRange = ""
elif ',' not in self.changeRange:
- self.revision = self.changeRange
+ revision = self.changeRange
self.changeRange = ""
p = p[:atIdx]
elif p.find("#") != -1:
hashIdx = p.index("#")
- self.revision = p[hashIdx:]
+ revision = p[hashIdx:]
p = p[:hashIdx]
elif self.previousDepotPaths == []:
- self.revision = "#head"
+ revision = "#head"
p = re.sub ("\.\.\.$", "", p)
if not p.endswith("/"):
@@ -1259,49 +1455,8 @@ class P4Sync(Command):
self.gitStream = importProcess.stdin
self.gitError = importProcess.stderr
- if self.revision:
- print "Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), self.revision, self.branch)
-
- details = { "user" : "git perforce import user", "time" : int(time.time()) }
- details["desc"] = ("Initial import of %s from the state at revision %s"
- % (' '.join(self.depotPaths), self.revision))
- details["change"] = self.revision
- newestRevision = 0
-
- fileCnt = 0
- for info in p4CmdList("files "
- + ' '.join(["%s...%s"
- % (p, self.revision)
- for p in self.depotPaths])):
-
- if info['code'] == 'error':
- sys.stderr.write("p4 returned an error: %s\n"
- % info['data'])
- sys.exit(1)
-
-
- change = int(info["change"])
- if change > newestRevision:
- newestRevision = change
-
- if info["action"] == "delete":
- # don't increase the file cnt, otherwise details["depotFile123"] will have gaps!
- #fileCnt = fileCnt + 1
- continue
-
- for prop in ["depotFile", "rev", "action", "type" ]:
- details["%s%s" % (prop, fileCnt)] = info[prop]
-
- fileCnt = fileCnt + 1
-
- details["change"] = newestRevision
- self.updateOptionDict(details)
- try:
- self.commit(details, self.extractFilesFromCommit(details), self.branch, self.depotPaths)
- except IOError:
- print "IO error with git fast-import. Is your git version recent enough?"
- print self.gitError.read()
-
+ if revision:
+ self.importHeadRevision(revision)
else:
changes = []
@@ -1319,15 +1474,7 @@ class P4Sync(Command):
if self.verbose:
print "Getting p4 changes for %s...%s" % (', '.join(self.depotPaths),
self.changeRange)
- assert self.depotPaths
- output = read_pipe_lines("p4 changes " + ' '.join (["%s...%s" % (p, self.changeRange)
- for p in self.depotPaths]))
-
- for line in output:
- changeNum = line.split(" ")[1]
- changes.append(int(changeNum))
-
- changes.sort()
+ changes = p4ChangesForPaths(self.depotPaths, self.changeRange)
if len(self.maxChanges) > 0:
changes = changes[:min(int(self.maxChanges), len(changes))]
@@ -1342,74 +1489,7 @@ class P4Sync(Command):
self.updatedBranches = set()
- cnt = 1
- for change in changes:
- description = p4Cmd("describe %s" % change)
- self.updateOptionDict(description)
-
- if not self.silent:
- sys.stdout.write("\rImporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
- sys.stdout.flush()
- cnt = cnt + 1
-
- try:
- if self.detectBranches:
- branches = self.splitFilesIntoBranches(description)
- for branch in branches.keys():
- ## HACK --hwn
- branchPrefix = self.depotPaths[0] + branch + "/"
-
- parent = ""
-
- filesForCommit = branches[branch]
-
- if self.verbose:
- print "branch is %s" % branch
-
- self.updatedBranches.add(branch)
-
- if branch not in self.createdBranches:
- self.createdBranches.add(branch)
- parent = self.knownBranches[branch]
- if parent == branch:
- parent = ""
- elif self.verbose:
- print "parent determined through known branches: %s" % parent
-
- # main branch? use master
- if branch == "main":
- branch = "master"
- else:
-
- ## FIXME
- branch = self.projectName + branch
-
- if parent == "main":
- parent = "master"
- elif len(parent) > 0:
- ## FIXME
- parent = self.projectName + parent
-
- branch = self.refPrefix + branch
- if len(parent) > 0:
- parent = self.refPrefix + parent
-
- if self.verbose:
- print "looking for initial parent for %s; current parent is %s" % (branch, parent)
-
- if len(parent) == 0 and branch in self.initialParents:
- parent = self.initialParents[branch]
- del self.initialParents[branch]
-
- self.commit(description, filesForCommit, branch, [branchPrefix], parent)
- else:
- files = self.extractFilesFromCommit(description)
- self.commit(description, files, self.branch, self.depotPaths,
- self.initialParent)
- self.initialParent = ""
- except IOError:
- print self.gitError.read()
- sys.exit(1)
+ self.importChanges(changes)
if not self.silent:
print ""
@@ -1419,7 +1499,6 @@ class P4Sync(Command):
sys.stdout.write("%s " % b)
sys.stdout.write("\n")
-
self.gitStream.close()
if importProcess.wait() != 0:
die("fast-import failed: %s" % self.gitError.read())
@@ -1440,6 +1519,9 @@ class P4Rebase(Command):
sync = P4Sync()
sync.run([])
+ return self.rebase()
+
+ def rebase(self):
[upstream, settings] = findUpstreamBranchPoint()
if len(upstream) == 0:
die("Cannot find upstream branchpoint for rebase")
diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index c6e154a..2838546 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -48,6 +48,12 @@ then
"a complete repository."
fi
+# don't recreate a workdir over an existing repository
+if test -e "$new_workdir"
+then
+ die "destination directory '$new_workdir' already exists."
+fi
+
# make sure the the links use full paths
git_dir=$(cd "$git_dir"; pwd)
diff --git a/diff.c b/diff.c
index 0d30d05..1aca5df 100644
--- a/diff.c
+++ b/diff.c
@@ -3144,6 +3144,22 @@ static void diffcore_apply_filter(const char *filter)
*q = outq;
}
+/* Check whether two filespecs with the same mode and size are identical */
+static int diff_filespec_is_identical(struct diff_filespec *one,
+ struct diff_filespec *two)
+{
+ if (S_ISGITLINK(one->mode)) {
+ diff_fill_sha1_info(one);
+ diff_fill_sha1_info(two);
+ return !hashcmp(one->sha1, two->sha1);
+ }
+ if (diff_populate_filespec(one, 0))
+ return 0;
+ if (diff_populate_filespec(two, 0))
+ return 0;
+ return !memcmp(one->data, two->data, one->size);
+}
+
static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
{
int i;
@@ -3175,10 +3191,7 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)
diff_populate_filespec(p->one, 1) ||
diff_populate_filespec(p->two, 1) ||
(p->one->size != p->two->size) ||
-
- diff_populate_filespec(p->one, 0) || /* (2) */
- diff_populate_filespec(p->two, 0) ||
- memcmp(p->one->data, p->two->data, p->one->size))
+ !diff_filespec_is_identical(p->one, p->two)) /* (2) */
diff_q(&outq, p);
else {
/*
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index ba23eb8..2954fb8 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -779,7 +779,7 @@ sub commit {
$xtag =~ tr/_/\./ if ( $opt_u );
$xtag =~ s/[\/]/$opt_s/g;
- system('git-tag', $xtag, $cid) == 0
+ system('git-tag', '-f', $xtag, $cid) == 0
or die "Cannot create tag $xtag: $!\n";
print "Created tag '$xtag' on '$branch'\n" if $opt_v;
diff --git a/git-rebase.sh b/git-rebase.sh
index 3bd66b0..c9942f2 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -216,9 +216,11 @@ do
-v|--verbose)
verbose=t
;;
+ --whitespace=*)
+ git_am_opt="$git_am_opt $1"
+ ;;
-C*)
- git_am_opt=$1
- shift
+ git_am_opt="$git_am_opt $1"
;;
-*)
usage
diff --git a/git-send-email.perl b/git-send-email.perl
index e0b7d12..dd7560b 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -73,9 +73,18 @@ Options:
--signed-off-cc Automatically add email addresses that appear in
Signed-off-by: or Cc: lines to the cc: list. Defaults to on.
+ --identity The configuration identity, a subsection to prioritise over
+ the default section.
+
--smtp-server If set, specifies the outgoing SMTP server to use.
Defaults to localhost.
+ --smtp-user The username for SMTP-AUTH.
+
+ --smtp-pass The password for SMTP-AUTH.
+
+ --smtp-ssl If set, connects to the SMTP server using SSL.
+
--suppress-from Suppress sending emails to yourself if your address
appears in a From: line. Defaults to off.
@@ -145,7 +154,6 @@ my $compose_filename = ".msg.$$";
my (@to,@cc,@initial_cc,@bcclist,@xh,
$initial_reply_to,$initial_subject,@files,$author,$sender,$compose,$time);
-my $smtp_server;
my $envelope_sender;
# Example reply to:
@@ -164,24 +172,26 @@ my ($quiet, $dry_run) = (0, 0);
# Variables with corresponding config settings
my ($thread, $chain_reply_to, $suppress_from, $signed_off_cc, $cc_cmd);
+my ($smtp_server, $smtp_authuser, $smtp_authpass, $smtp_ssl);
+my ($identity, $aliasfiletype, @alias_files);
-my %config_settings = (
+my %config_bool_settings = (
"thread" => [\$thread, 1],
"chainreplyto" => [\$chain_reply_to, 1],
"suppressfrom" => [\$suppress_from, 0],
"signedoffcc" => [\$signed_off_cc, 1],
- "cccmd" => [\$cc_cmd, ""],
+ "smtpssl" => [\$smtp_ssl, 0],
);
-foreach my $setting (keys %config_settings) {
- my $config = $repo->config_bool("sendemail.$setting");
- ${$config_settings{$setting}->[0]} = (defined $config) ? $config : $config_settings{$setting}->[1];
-}
-
-@bcclist = $repo->config('sendemail.bcc');
-if (!@bcclist or !$bcclist[0]) {
- @bcclist = ();
-}
+my %config_settings = (
+ "smtpserver" => \$smtp_server,
+ "smtpuser" => \$smtp_authuser,
+ "smtppass" => \$smtp_authpass,
+ "cccmd" => \$cc_cmd,
+ "aliasfiletype" => \$aliasfiletype,
+ "bcc" => \@bcclist,
+ "aliasesfile" => \@alias_files,
+);
# Begin by accumulating all the variables (defined above), that we will end up
# needing, first, from the command line:
@@ -194,6 +204,10 @@ my $rc = GetOptions("sender|from=s" => \$sender,
"bcc=s" => \@bcclist,
"chain-reply-to!" => \$chain_reply_to,
"smtp-server=s" => \$smtp_server,
+ "smtp-user=s" => \$smtp_authuser,
+ "smtp-pass=s" => \$smtp_authpass,
+ "smtp-ssl!" => \$smtp_ssl,
+ "identity=s" => \$identity,
"compose" => \$compose,
"quiet" => \$quiet,
"cc-cmd=s" => \$cc_cmd,
@@ -208,6 +222,43 @@ unless ($rc) {
usage();
}
+# Now, let's fill any that aren't set in with defaults:
+
+sub read_config {
+ my ($prefix) = @_;
+
+ foreach my $setting (keys %config_bool_settings) {
+ my $target = $config_bool_settings{$setting}->[0];
+ $$target = $repo->config_bool("$prefix.$setting") unless (defined $$target);
+ }
+
+ foreach my $setting (keys %config_settings) {
+ my $target = $config_settings{$setting};
+ if (ref($target) eq "ARRAY") {
+ unless (@$target) {
+ my @values = $repo->config("$prefix.$setting");
+ @$target = @values if (@values && defined $values[0]);
+ }
+ }
+ else {
+ $$target = $repo->config("$prefix.$setting") unless (defined $$target);
+ }
+ }
+}
+
+# read configuration from [sendemail "$identity"], fall back on [sendemail]
+$identity = $repo->config("sendemail.identity") unless (defined $identity);
+read_config("sendemail.$identity") if (defined $identity);
+read_config("sendemail");
+
+# fall back on builtin bool defaults
+foreach my $setting (values %config_bool_settings) {
+ ${$setting->[0]} = $setting->[1] unless (defined (${$setting->[0]}));
+}
+
+my ($repoauthor) = $repo->ident_person('author');
+my ($repocommitter) = $repo->ident_person('committer');
+
# Verify the user input
foreach my $entry (@to) {
@@ -222,14 +273,7 @@ foreach my $entry (@bcclist) {
die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
}
-# Now, let's fill any that aren't set in with defaults:
-
-my ($repoauthor) = $repo->ident_person('author');
-my ($repocommitter) = $repo->ident_person('committer');
-
my %aliases;
-my @alias_files = $repo->config('sendemail.aliasesfile');
-my $aliasfiletype = $repo->config('sendemail.aliasfiletype');
my %parse_alias = (
# multiline formats can be supported in the future
mutt => sub { my $fh = shift; while (<$fh>) {
@@ -320,10 +364,7 @@ if ($thread && !defined $initial_reply_to && $prompting) {
$initial_reply_to =~ s/(^\s+|\s+$)//g;
}
-if (!$smtp_server) {
- $smtp_server = $repo->config('sendemail.smtpserver');
-}
-if (!$smtp_server) {
+if (!defined $smtp_server) {
foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
if (-x $_) {
$smtp_server = $_;
@@ -553,8 +594,16 @@ X-Mailer: git-send-email $gitversion
print $sm "$header\n$message";
close $sm or die $?;
} else {
- require Net::SMTP;
- $smtp ||= Net::SMTP->new( $smtp_server );
+ if ($smtp_ssl) {
+ require Net::SMTP::SSL;
+ $smtp ||= Net::SMTP::SSL->new( $smtp_server, Port => 465 );
+ }
+ else {
+ require Net::SMTP;
+ $smtp ||= Net::SMTP->new( $smtp_server );
+ }
+ $smtp->auth( $smtp_authuser, $smtp_authpass )
+ or die $smtp->message if (defined $smtp_authuser);
$smtp->mail( $raw_from ) or die $smtp->message;
$smtp->to( @recipients ) or die $smtp->message;
$smtp->data or die $smtp->message;
@@ -661,7 +710,7 @@ foreach my $t (@files) {
}
close F;
- if ($cc_cmd ne "") {
+ if (defined $cc_cmd) {
open(F, "$cc_cmd $t |")
or die "(cc-cmd) Could not execute '$cc_cmd'";
while(<F>) {
diff --git a/git-svn.perl b/git-svn.perl
index d3c8cd0..f818160 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -841,14 +841,9 @@ sub working_head_info {
sub read_commit_parents {
my ($parents, $c) = @_;
- my ($fh, $ctx) = command_output_pipe(qw/cat-file commit/, $c);
- while (<$fh>) {
- chomp;
- last if '';
- /^parent ($sha1)/ or next;
- push @{$parents->{$c}}, $1;
- }
- close $fh; # break the pipe
+ chomp(my $p = command_oneline(qw/rev-list --parents -1/, $c));
+ $p =~ s/^($c)\s*// or die "rev-list --parents -1 $c failed!\n";
+ @{$parents->{$c}} = split(/ /, $p);
}
sub linearize_history {
@@ -3013,7 +3008,7 @@ package Git::SVN::Ra;
use vars qw/@ISA $config_dir $_log_window_size/;
use strict;
use warnings;
-my ($can_do_switch, %ignored_err, $RA);
+my ($ra_invalid, $can_do_switch, %ignored_err, $RA);
BEGIN {
# enforce temporary pool usage for some simple functions
@@ -3174,7 +3169,11 @@ sub gs_do_switch {
$self->{url} = $full_url;
$reparented = 1;
} else {
+ $_[0] = undef;
+ $self = undef;
+ $RA = undef;
$ra = Git::SVN::Ra->new($full_url);
+ $ra_invalid = 1;
}
}
$ra ||= $self;
@@ -3234,6 +3233,7 @@ sub gs_fetch_loop_common {
my $inc = $_log_window_size;
my ($min, $max) = ($base, $head < $base + $inc ? $head : $base + $inc);
my $longest_path = longest_common_path($gsv, $globs);
+ my $ra_url = $self->{url};
while (1) {
my %revs;
my $err;
@@ -3295,6 +3295,13 @@ sub gs_fetch_loop_common {
"$g->{t}-maxRev";
Git::SVN::tmp_config($k, $r);
}
+ if ($ra_invalid) {
+ $_[0] = undef;
+ $self = undef;
+ $RA = undef;
+ $self = Git::SVN::Ra->new($ra_url);
+ $ra_invalid = undef;
+ }
}
# pre-fill the .rev_db since it'll eventually get filled in
# with '0' x40 if something new gets committed
diff --git a/git-svnimport.perl b/git-svnimport.perl
index 8c17fb5..d3ad5b9 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -873,7 +873,7 @@ sub commit {
$dest =~ tr/_/\./ if $opt_u;
- system('git-tag', $dest, $cid) == 0
+ system('git-tag', '-f', $dest, $cid) == 0
or die "Cannot create tag $dest: $!\n";
print "Created tag '$dest' on '$branch'\n" if $opt_v;
diff --git a/refs.c b/refs.c
index 09a2c87..7fb3350 100644
--- a/refs.c
+++ b/refs.c
@@ -1455,3 +1455,30 @@ int for_each_reflog(each_ref_fn fn, void *cb_data)
{
return do_for_each_reflog("", fn, cb_data);
}
+
+int update_ref(const char *action, const char *refname,
+ const unsigned char *sha1, const unsigned char *oldval,
+ int flags, enum action_on_err onerr)
+{
+ static struct ref_lock *lock;
+ lock = lock_any_ref_for_update(refname, oldval, flags);
+ if (!lock) {
+ const char *str = "Cannot lock the ref '%s'.";
+ switch (onerr) {
+ case MSG_ON_ERR: error(str, refname); break;
+ case DIE_ON_ERR: die(str, refname); break;
+ case QUIET_ON_ERR: break;
+ }
+ return 1;
+ }
+ if (write_ref_sha1(lock, sha1, action) < 0) {
+ const char *str = "Cannot update the ref '%s'.";
+ switch (onerr) {
+ case MSG_ON_ERR: error(str, refname); break;
+ case DIE_ON_ERR: die(str, refname); break;
+ case QUIET_ON_ERR: break;
+ }
+ return 1;
+ }
+ return 0;
+}
diff --git a/refs.h b/refs.h
index f234eb7..6eb98a4 100644
--- a/refs.h
+++ b/refs.h
@@ -64,4 +64,10 @@ extern int rename_ref(const char *oldref, const char *newref, const char *logmsg
/** resolve ref in nested "gitlink" repository */
extern int resolve_gitlink_ref(const char *name, const char *refname, unsigned char *result);
+/** lock a ref and then write its file */
+enum action_on_err { MSG_ON_ERR, DIE_ON_ERR, QUIET_ON_ERR };
+int update_ref(const char *action, const char *refname,
+ const unsigned char *sha1, const unsigned char *oldval,
+ int flags, enum action_on_err onerr);
+
#endif /* REFS_H */
diff --git a/send-pack.c b/send-pack.c
index 9fc8a81..f74e66a 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -307,20 +307,14 @@ static int send_pack(int in, int out, struct remote *remote, int nr_refspec, cha
rs.src = ref->name;
rs.dst = NULL;
if (!remote_find_tracking(remote, &rs)) {
- struct ref_lock *lock;
fprintf(stderr, " Also local %s\n", rs.dst);
if (will_delete_ref) {
if (delete_ref(rs.dst, NULL)) {
error("Failed to delete");
}
- } else {
- lock = lock_any_ref_for_update(rs.dst, NULL, 0);
- if (!lock)
- error("Failed to lock");
- else
- write_ref_sha1(lock, ref->new_sha1,
- "update by push");
- }
+ } else
+ update_ref("update by push", rs.dst,
+ ref->new_sha1, NULL, 0, 0);
free(rs.dst);
}
}
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index c4c0dfa..ce045b2 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -198,11 +198,9 @@ test_expect_success \
GIT_AUTHOR_DATE="2005-05-26 23:41" \
GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
h_OTHER=$(git rev-parse --verify HEAD) &&
- echo FIXED >F &&
GIT_AUTHOR_DATE="2005-05-26 23:44" \
GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
h_FIXED=$(git rev-parse --verify HEAD) &&
- echo TEST+FIXED >F &&
echo Merged initial commit and a later commit. >M &&
echo $h_TEST >.git/MERGE_HEAD &&
GIT_AUTHOR_DATE="2005-05-26 23:45" \
diff --git a/t/t4123-apply-shrink.sh b/t/t4123-apply-shrink.sh
new file mode 100755
index 0000000..984157f
--- /dev/null
+++ b/t/t4123-apply-shrink.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+test_description='apply a patch that is larger than the preimage'
+
+. ./test-lib.sh
+
+cat >F <<\EOF
+1
+2
+3
+4
+5
+6
+7
+8
+999999
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+
+EOF
+
+test_expect_success setup '
+
+ git add F &&
+ mv F G &&
+ sed -e "s/1/11/" -e "s/999999/9/" -e "s/H/HH/" <G >F &&
+ git diff >patch &&
+ sed -e "/^\$/d" <G >F &&
+ git add F
+
+'
+
+test_expect_success 'apply should fail gracefully' '
+
+ if git apply --index patch
+ then
+ echo Oops, should not have succeeded
+ false
+ else
+ status=$?
+ echo "Status was $status"
+ if test -f .git/index.lock
+ then
+ echo Oops, should not have crashed
+ false
+ fi
+ fi
+'
+
+test_done
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 606d4f2..0d07bc3 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -990,6 +990,13 @@ test_expect_success \
git diff expect actual
'
+# try to sign with bad user.signingkey
+git config user.signingkey BobTheMouse
+test_expect_failure \
+ 'git-tag -s fails if gpg is misconfigured' \
+ 'git tag -s -m tail tag-gpg-failure'
+git config --unset user.signingkey
+
# try to verify without gpg:
rm -rf gpghome
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 9d142ed..4fe3a41 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -152,6 +152,10 @@ test_expect_success 'the --cached sha1 should be rev1' '
git-submodule --cached status | grep "^+$rev1"
'
+test_expect_success 'git diff should report the SHA1 of the new submodule commit' '
+ git-diff | grep "^+Subproject commit $rev2"
+'
+
test_expect_success 'update should checkout rev1' '
git-submodule update &&
head=$(cd lib && git rev-parse HEAD) &&