git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] revert/cherry-pick: allow starting from dirty work tree.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2007, 21:16 UTC
Message-ID
<7vd4udsv6b.fsf@gitster.siamese.dyndns.org>

There is no reason to forbid a dirty work tree when reverting or cherry-picking a change, as long as the index is clean.

The scripted version used to allow it:
    case "$no_commit" in
    t)
    	# We do not intend to commit immediately.  We just want to
    	# merge the differences in.
    	head=$(git-write-tree) ||
    		die "Your index file is unmerged."
    	;;
    *)
    	head=$(git-rev-parse --verify HEAD) ||
    		die "You do not have a valid HEAD"
    	files=$(git-diff-index --cached --name-only $head) || exit
    	if [ "$files" ]; then
    		die "Dirty index: cannot $me (dirty: $files)"
    	fi
    	;;
    esac
but C rewrite tightened the check, probably by mistake.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-revert.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-revert.c b/builtin-revert.c
index cef7147..f704197 100644
--- a/builtin-revert.c
+++ b/builtin-revert.c
@@ -272,7 +272,7 @@ static int revert_or_cherry_pick(int argc, const char **argv)
 		if (get_sha1("HEAD", head))
 			die ("You do not have a valid HEAD");
 		wt_status_prepare(&s);
-		if (s.commitable || s.workdir_dirty)
+		if (s.commitable)
 			die ("Dirty index: cannot %s", me);
 		discard_cache();
 	}
-- 
1.5.3.5.1728.g34b3e
Next: Johannes Schindelin
Message 1 of 4 in “revert/cherry-pick: allow starting from dirty work tree.”
  1. revert/cherry-pick: allow starting from dirty work tree.Junio C Hamano, Nov 13, 2007
  2. Johannes SchindelinNov 13, 2007
  3. Jakub NarebskiNov 14, 2007
  4. Junio C HamanoNov 14, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.