From d37fd03222ad6b38aa6e237f5f191238c0544850 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 29 Jan 2006 14:52:16 -0800 Subject: [PATCH] pre-commit sample hook: do not barf on the initial import The example hook barfs on the initial import. Ideally it should produce a diff from an empty tree, but for now let's stop at squelching the bogus error message. Often an initial import involves tons of badly formatted files from foreign SCM, so not complaining about them like this patch does might actually be a better idea than enforcing the "Perfect Patch" format on them. Signed-off-by: Junio C Hamano --- templates/hooks--pre-commit | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/templates/hooks--pre-commit b/templates/hooks--pre-commit index 4bb6803b10..43d3b6ef4a 100644 --- a/templates/hooks--pre-commit +++ b/templates/hooks--pre-commit @@ -10,8 +10,16 @@ # This is slightly modified from Andrew Morton's Perfect Patch. # Lines you introduce should not have trailing whitespace. # Also check for an indentation that has SP before a TAB. + +if git-rev-parse --verify HEAD 2>/dev/null +then + git-diff-index -p -M --cached HEAD +else + # NEEDSWORK: we should produce a diff with an empty tree here + # if we want to do the same verification for the initial import. + : +fi | perl -e ' - my $fh; my $found_bad = 0; my $filename; my $reported_filename = ""; @@ -31,8 +39,7 @@ perl -e ' print STDERR "* $why (line $lineno)\n"; print STDERR "$filename:$lineno:$line\n"; } - open $fh, "-|", qw(git-diff-index -p -M --cached HEAD); - while (<$fh>) { + while (<>) { if (m|^diff --git a/(.*) b/\1$|) { $filename = $1; next; -- cgit v1.2.3 From 4353f386166d74fd96cb552900fc22f6df211c21 Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Sun, 29 Jan 2006 13:16:08 +0100 Subject: merge-recursive: Improve the error message printed when merge(1) isn't found. Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- git-merge-recursive.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/git-merge-recursive.py b/git-merge-recursive.py index 56c3641abb..b17c8e595e 100755 --- a/git-merge-recursive.py +++ b/git-merge-recursive.py @@ -205,11 +205,16 @@ def mergeFile(oPath, oSha, oMode, aPath, aSha, aMode, bPath, bSha, bMode, orig = runProgram(['git-unpack-file', oSha]).rstrip() src1 = runProgram(['git-unpack-file', aSha]).rstrip() src2 = runProgram(['git-unpack-file', bSha]).rstrip() - [out, code] = runProgram(['merge', - '-L', branch1Name + '/' + aPath, - '-L', 'orig/' + oPath, - '-L', branch2Name + '/' + bPath, - src1, orig, src2], returnCode=True) + try: + [out, code] = runProgram(['merge', + '-L', branch1Name + '/' + aPath, + '-L', 'orig/' + oPath, + '-L', branch2Name + '/' + bPath, + src1, orig, src2], returnCode=True) + except ProgramError, e: + print >>sys.stderr, e + die("Failed to execute 'merge'. merge(1) is used as the " + "file-level merge tool. Is 'merge' in your path?") sha = runProgram(['git-hash-object', '-t', 'blob', '-w', src1]).rstrip() -- cgit v1.2.3 From 075dd8ee5417899c9f41b90f0dceecdf85433468 Mon Sep 17 00:00:00 2001 From: Fredrik Kuivinen Date: Sun, 29 Jan 2006 15:02:51 +0100 Subject: git-branch: Documentation fixes Signed-off-by: Fredrik Kuivinen Signed-off-by: Junio C Hamano --- Documentation/git-branch.txt | 7 +++++-- git-branch.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index d20b475735..b1bc8272eb 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -7,7 +7,7 @@ git-branch - Create a new branch, or remove an old one. SYNOPSIS -------- -'git-branch' [-d | -D] [ [start-point]] +'git-branch' [(-d | -D) ] | [[-f] []] DESCRIPTION ----------- @@ -25,10 +25,13 @@ OPTIONS -D:: Delete a branch irrespective of its index status. +-f:: + Force a reset of to (or current head). + :: The name of the branch to create or delete. -start-point:: +:: Where to create the branch; defaults to HEAD. This option has no meaning with -d and -D. diff --git a/git-branch.sh b/git-branch.sh index b0e54ed2af..6ac961e6d1 100755 --- a/git-branch.sh +++ b/git-branch.sh @@ -1,6 +1,6 @@ #!/bin/sh -USAGE='[-d ] | [[-f] [start-point]]' +USAGE='[(-d | -D) ] | [[-f] []]' LONG_USAGE='If no arguments, show available branches and mark current branch with a star. If one argument, create a new branch based off of current HEAD. If two arguments, create a new branch based off of .' -- cgit v1.2.3 From f0fff36e82bc8cc12be58a0585106ee720c4dc98 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" Date: Sun, 29 Jan 2006 20:40:50 -0500 Subject: git push -f documentation Signed-off-by: Junio C Hamano --- Documentation/git-push.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt index 2254bac16e..29fa30752e 100644 --- a/Documentation/git-push.txt +++ b/Documentation/git-push.txt @@ -30,10 +30,10 @@ include::pull-fetch-param.txt[] to be pushed. -f, \--force:: - Usually, the command refuses to update a local ref that is - not an ancestor of the remote ref used to overwrite it. - This flag disables the check. What this means is that the - local repository can lose commits; use it with care. + Usually, the command refuses to update a remote ref that is + not a descendent of the local ref used to overwrite it. + This flag disables the check. This can cause the + remote repository to lose commits; use it with care. Author -- cgit v1.2.3