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

Git cancel work

From
DWDan Weber <dan@mirrorlynx.com>
Date
Apr 24, 2005, 04:34 UTC
Message-ID
<Pine.LNX.4.62.0504240033230.1980@mirrorlynx.com>

I noticed that git cancel was always doing a full checkout. So I figured, "what about just checking out the modified files?". Attached is a patch to do so.

Dan
Lets not do a full checkout on git cancel

--- commit 47197d9accb420ec55f6dfd63d990d4fb2537330 tree e8f3699877dd220440808087632ef87cce2288a7 parent c83b95297c2a6336c2007548f909769e0862b509 author Dan Weber <dan@mirrorlynx.com> 1114316504 -0400 committer Dan Weber <dan@mirrorlynx.com> 1114316504 -0400

Index: gitcancel.sh
===================================================================
--- 2aaf94eae20acc451553766f3c063bc46cfa75c6/gitcancel.sh  (mode:100755 sha1:26eecb50bc812211454e98d98e8818387ae97df5)
+++ e8f3699877dd220440808087632ef87cce2288a7/gitcancel.sh  (mode:100755 sha1:c836b75bb8a7c461b2d0ad536d1c3bc2d2440ab4)
@@ -2,6 +2,7 @@
 #
 # Cancels current edits in the working tree.
 # Copyright (c) Petr Baudis, 2005
+# Copyright (c) Dan Weber, 2005
 #
 # This script reverts the working tree to a consistent state before
 # any changes to it (including merges etc) were done.
@@ -26,5 +27,23 @@
 rm -f .git/blocked .git/merging .git/merging-sym .git/merge-base
 read-tree -m $(tree-id) || read-tree $(tree-id)
 
-checkout-cache -f -a
-update-cache --refresh
+general() {
+	for name in $(diff-cache -r $(tree-id)|awk '{print $4}')
+	do
+		checkout-cache -f $name
+	done
+	update-cache --refresh
+}
+
+full () {
+	checkout-cache -f -a
+	update-cache --refresh
+}
+
+
+if [ "$1" == "-a" -o "$1" == "--full" -o "$1" == "--all" ]; then
+	full
+else
+	general
+fi
+
Next: Petr Baudis
Message 1 of 6 in “Git cancel work”
  1. Dan WeberApr 24, 2005
  2. Petr BaudisApr 24, 2005
  3. Dan WeberApr 24, 2005
  4. Petr BaudisApr 24, 2005
  5. Dan WeberApr 24, 2005
  6. Dan HolmsandApr 24, 2005

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.