From 3b21a438c99b38c772247201d30b7ee80b278463 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 26 Jan 2011 19:26:59 -0500 Subject: rebase: use explicit "--" with checkout In the case of a ref/pathname conflict, checkout will already do the right thing and checkout the ref. However, for a non-existant ref, this has two advantages: 1. If a file with that pathname exists, rebase will refresh the file from the index and then rebase the current branch instead of producing an error. 2. If no such file exists, the error message using an explicit "--" is better: # before $ git rebase -i origin bogus error: pathspec 'bogus' did not match any file(s) known to git. Could not checkout bogus # after $ git rebase -i origin bogus fatal: invalid reference: bogus Could not checkout bogus The problems seem to be trigger-able only through "git rebase -i", as regular git-rebase checks the validity of the branch parameter as a ref very early on. However, it doesn't hurt to be defensive. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index a27952d..20ebd09 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -870,7 +870,7 @@ first and then run 'git rebase --continue' again." if test ! -z "$1" then - output git checkout "$1" || + output git checkout "$1" -- || die "Could not checkout $1" fi diff --git a/git-rebase.sh b/git-rebase.sh index 6a7e5e0..1f42fb7 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -522,7 +522,7 @@ then if test -z "$force_rebase" then # Lazily switch to the target branch if needed... - test -z "$switch_to" || git checkout "$switch_to" + test -z "$switch_to" || git checkout "$switch_to" -- say "Current branch $branch_name is up to date." exit 0 else -- cgit v0.10.2-6-g49f6 From 4ac5356c62d02b118c49cd85f88c7e6f65590400 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 26 Jan 2011 19:27:11 -0500 Subject: rebase: give a better error message for bogus branch When you give a non-existent branch to git-rebase, it spits out the usage. This can be confusing, since you may understand the usage just fine, but simply have made a mistake in the branch name. Before: $ git rebase origin bogus Usage: git rebase ... After: $ git rebase origin bogus fatal: no such branch: bogus Usage: git rebase ... Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/git-rebase.sh b/git-rebase.sh index 1f42fb7..26d5197 100755 --- a/git-rebase.sh +++ b/git-rebase.sh @@ -491,6 +491,7 @@ case "$#" in then head_name="detached HEAD" else + echo >&2 "fatal: no such branch: $1" usage fi ;; -- cgit v0.10.2-6-g49f6 From 8fe533f686e20852fa9bd2df2755faed7c7bcdcc Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 27 Jan 2011 00:07:49 -0600 Subject: fast-import: treat filemodify with empty tree as delete Normal git processes do not allow one to build a tree with an empty subtree entry without trying hard at it. This is in keeping with the general UI philosophy: git tracks content, not empty directories. v1.7.3-rc0~75^2 (2010-06-30) changed that by making it easy to include an empty subtree in fast-import's active commit: M 040000 4b825dc642cb6eb9a060e54bf8d69288fbee4904 subdir One can trigger this by reading an empty tree (for example, the tree corresponding to an empty root commit) and trying to move it to a subtree. It is better and more closely analogous to 'git read-tree --prefix' to treat such commands as requests to remove the subtree. Noticed-by: David Barr Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/fast-import.c b/fast-import.c index ad6843a..cd9310d 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2163,6 +2163,12 @@ static void file_change_m(struct branch *b) p = uq.buf; } + /* Git does not track empty, non-toplevel directories. */ + if (S_ISDIR(mode) && !memcmp(sha1, EMPTY_TREE_SHA1_BIN, 20) && *p) { + tree_content_remove(&b->branch_tree, p, NULL); + return; + } + if (S_ISGITLINK(mode)) { if (inline_data) die("Git links cannot be specified 'inline': %s", diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh index 50d5913..8487734 100755 --- a/t/t9300-fast-import.sh +++ b/t/t9300-fast-import.sh @@ -818,6 +818,48 @@ test_expect_success \ compare_diff_raw expect actual' test_expect_success \ + 'N: delete directory by copying' \ + 'cat >expect <<-\EOF && + OBJID + :100644 000000 OBJID OBJID D foo/bar/qux + OBJID + :000000 100644 OBJID OBJID A foo/bar/baz + :000000 100644 OBJID OBJID A foo/bar/qux + EOF + empty_tree=$(git mktree input <<-INPUT_END && + commit refs/heads/N-delete + committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE + data < $GIT_COMMITTER_DATE + data <actual && + test_cmp expect actual' + +test_expect_success \ 'N: modify copied tree' \ 'cat >expect <<-\EOF && :100644 100644 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 fcf778cda181eaa1cbc9e9ce3a2e15ee9f9fe791 C100 newdir/interesting file3/file5 -- cgit v0.10.2-6-g49f6 From a1231de0020b60076f946012b8230db9b1c00cfd Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 26 Jan 2011 15:33:32 -0500 Subject: tests: sanitize more git environment variables These variables should generally not be set in one's environment, but they do get set by rebase, which means doing an interactive rebase like: pick abcd1234 foo exec make test will cause false negatives in the test suite. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/t/test-lib.sh b/t/test-lib.sh index 1fb76ab..7ffd7d3 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -70,6 +70,9 @@ unset GIT_NOTES_REF unset GIT_NOTES_DISPLAY_REF unset GIT_NOTES_REWRITE_REF unset GIT_NOTES_REWRITE_MODE +unset GIT_REFLOG_ACTION +unset GIT_CHERRY_PICK_HELP +unset GIT_QUIET GIT_MERGE_VERBOSITY=5 export GIT_MERGE_VERBOSITY export GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME -- cgit v0.10.2-6-g49f6 From 960ac5ff99304404d287b8174d7c8a7743c6d97a Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Thu, 20 Jan 2011 18:36:24 -0600 Subject: rebase -i: clarify in-editor documentation of "exec" The hints in the current "instruction sheet" template look like so: # Rebase 3f14246..a1d7e01 onto 3f14246 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x , exec = Run a shell command , and stop if it fails # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. # This does not make it clear that the format of each line is but the reader will probably infer that from the automatically generated pick examples above it. What about the "exec" instruction? By analogy, I might imagine that the format of that line is "exec ", and the "x " hint does not address that question (at first I read it as taking an argument that is the name of a shell). Meanwhile, the mention of makes the hints harder to scan as a table. So remove the and add some words to remind the reader that "exec" runs a command named by the rest of the line. To make room, it is left to the manpage to explain that that command is run using $SHELL and that nonzero status from that command will pause the rebase. Wording from Junio. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 20ebd09..9f01775 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -997,7 +997,7 @@ first and then run 'git rebase --continue' again." # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message -# x , exec = Run a shell command , and stop if it fails +# x, exec = run command (the rest of the line) using shell # # If you remove a line here THAT COMMIT WILL BE LOST. # However, if you remove everything, the rebase will be aborted. -- cgit v0.10.2-6-g49f6