Skip to contentSkip to conversation

Add git-ls-files -k option.

PATCH New Junio C Hamano 1 participant 2 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add git-ls-files -k option.

Pasky, you may remember the discussion on how "chilly" the proposed behaviour of checkout-cache -f obliterating conflicting paths was, and what I think is needed for the Porcelain layer if it chooses to save such files before checking things out.

Here is a patch to add -k (killed) option to git-ls-files to find out what files are need to be killed to make checkout-cache to succeed. The Porcelain can run it immediately before checkout-cache, save the files reported, and the run checkout-cache -f. If your checkout-cache does not have that "chilly" enhancement, in addition to saving the files above, it also has to move them out of the way.

Note: To be applied after ls-files --other symlink fix.

------------

When checkout-cache attempts to check out a non-directory where a directory exists on the work tree, or to check out a file under directory D when path D is a non-directory on the work tree, the attempt fails. Before running checkout-cache, the user can run git-ls-files with the -k (killed) option to get a list of such paths.

This also includes the test for this functionality and documentation of the new option.

---

Documentation/git-ls-files.txt |   10 +++-
ls-files.c                     |   95 +++++++++++++++++++++++++++++++++--------
t/t0500-ls-files.sh            |   55 +++++++++++++++++++++++
3 files changed, 140 insertions(+), 20 deletions(-)
Documentation/git-ls-files.txt +8 -2
@@ -10,8 +10,8 @@ git-ls-files - Information about files i
 SYNOPSIS
 --------
 'git-ls-files' [-z] [-t]
-		(--[cached|deleted|others|ignored|stage|unmerged])\*
-		(-[c|d|o|i|s|u])\*
+		(--[cached|deleted|others|ignored|stage|unmerged|killed])\*
+		(-[c|d|o|i|s|u|k])\*
 		[-x <pattern>|--exclude=<pattern>]
 		[-X <file>|--exclude-from=<file>]
 
@@ -45,6 +45,11 @@ OPTIONS
 -u|--unmerged::
 	Show unmerged files in the output (forces --stage)
 
+-k|--killed::
+	Show files on the filesystem that need to be removed due
+	to file/directory conflicts for checkout-cache to
+	succeed.
+
 -z::
 	\0 line termination on output
 
@@ -65,6 +70,7 @@ OPTIONS
 	H	cached
 	M	unmerged
 	R	removed/deleted
+	K	to be killed
 	?	other
 
 Output
ls-files.c +77 -18

162 lines not on this page · raw message

Created: t/t0500-ls-files.sh (mode:100755)

t/t0500-ls-files.sh new file +55 -0

55 lines not on this page · raw message

#1 lore raw

PATCH 1/1 Add git-ls-files -k (take 2).

When checkout-cache attempts to check out a non-directory where a directory exists on the work tree, or to check out a file under directory D when path D is a non-directory on the work tree, the attempt fails. Before running checkout-cache, the user can run git-ls-files with the -k (killed) option to get a list of such paths. The tagged output format uses "K" to denote such paths.

This also includes the test for this functionality and documentation of the new option.

---

*** This is a reworked patch that fixes performance problem in *** the one I sent out earlier. Discard the earlier one and *** apply this on top of "git-ls-files --others symlink fix".

Documentation/git-ls-files.txt |   10 +++-
ls-files.c                     |  101 ++++++++++++++++++++++++++++++++++-------
t/t0500-ls-files.sh            |   55 ++++++++++++++++++++++
3 files changed, 147 insertions(+), 19 deletions(-)
Documentation/git-ls-files.txt +8 -2
@@ -10,8 +10,8 @@ git-ls-files - Information about files i
 SYNOPSIS
 --------
 'git-ls-files' [-z] [-t]
-		(--[cached|deleted|others|ignored|stage|unmerged])\*
-		(-[c|d|o|i|s|u])\*
+		(--[cached|deleted|others|ignored|stage|unmerged|killed])\*
+		(-[c|d|o|i|s|u|k])\*
 		[-x <pattern>|--exclude=<pattern>]
 		[-X <file>|--exclude-from=<file>]
 
@@ -45,6 +45,11 @@ OPTIONS
 -u|--unmerged::
 	Show unmerged files in the output (forces --stage)
 
+-k|--killed::
+	Show files on the filesystem that need to be removed due
+	to file/directory conflicts for checkout-cache to
+	succeed.
+
 -z::
 	\0 line termination on output
 
@@ -65,6 +70,7 @@ OPTIONS
 	H	cached
 	M	unmerged
 	R	removed/deleted
+	K	to be killed
 	?	other
 
 Output
ls-files.c +84 -17

169 lines not on this page · raw message

Created: t/t0500-ls-files.sh (mode:100755)

t/t0500-ls-files.sh new file +55 -0

55 lines not on this page · raw message