[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-vc-dwim] [PATCH 3b/3] vc-chlog --stdin: try to cope with dirty work
From: |
Ralf Wildenhues |
Subject: |
[Bug-vc-dwim] [PATCH 3b/3] vc-chlog --stdin: try to cope with dirty workdir. |
Date: |
Sat, 12 Mar 2011 12:39:14 +0100 |
User-agent: |
Mutt/1.5.20 (2010-08-04) |
With 'git add -i', it can be helpful to pipe the output of
'git diff --cached' into 'vc-chlog --stdin'. However, if the
working directory also contains unrelated changes, then the tag
list might be wrong, because we try to recreate the old version
of the file from the copy in the working directory. Instead of
trying to reverse-apply the patch on stdin on top of that, try
'vc-dwim --diff' first, which can help to get back to the state
of the last commit. From there, recreate the version of the new
file with the patch from stdin.
* vc-chlog.in (func_extract_identifiers): If $stdin, recreate
the old file from 'vc-dwim --diff' if possibly, otherwise fall
back to the patch given on stdin. If $stdin, recreate a version
of the new file from this old file, rather than relying on the
version in the working directory.
* tests/Makefile.am (XFAIL_TESTS): Remove dirty-workdir.
* NEWS: Update.
Signed-off-by: Ralf Wildenhues <address@hidden>
---
NEWS | 2 ++
tests/Makefile.am | 3 ---
vc-chlog.in | 16 +++++++++++++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/NEWS b/NEWS
index ac5bd02..89929bc 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ vc-dwim NEWS -*-
outline -*-
vc-chlog can now handle two-word function names like "operator delete"
+ vc-chlog --stdin now tries to cope better with dirty working directories,
+ for 'git add -i' workflows.
* Noteworthy changes in release 1.3 (2010-11-06) [stable]
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3fd83c..1ceee3c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -25,7 +25,4 @@ TESTS = \
multiple-chlogs \
dirty-workdir
-XFAIL_TESTS = \
- dirty-workdir
-
include $(srcdir)/check.mk
diff --git a/vc-chlog.in b/vc-chlog.in
index a5bee47..0f01cc2 100755
--- a/vc-chlog.in
+++ b/vc-chlog.in
@@ -404,6 +404,8 @@ func_extract_identifiers ()
basename=`func_basename "$file"`
oldbase=oldfile-$nfile-$basename
oldfile=$tmp/$oldbase
+ newbase=newfile-$nfile-$basename
+ newfile=$tmp/$newbase
nidents=$tmp/nidents-$nfile
oidents=$tmp/oidents-$nfile
@@ -413,14 +415,22 @@ func_extract_identifiers ()
else
: >"$oldfile"
fi
- func_diff_for_file "$oldbase" | func_apply_tmp_patch -p0 -R "$oldbase"
+ if $stdin && vc-dwim --diff "$file" 2>/dev/null; then
+ :
+ else
+ func_diff_for_file "$oldbase"
+ fi | func_apply_tmp_patch -p0 -R "$oldbase"
# The file may be new, in which case $oldfile will be removed by patch.
if test -f "$oldfile"; then
func_taglist "$oldfile"
fi >"$tagfile-old"
- # Create the tag list from the new file.
- if test -f "$file"; then
+ # Recreate the new file if needed, and the tag list from it.
+ if $stdin && test -f "$oldfile"; then
+ cp "$oldfile" "$newfile"
+ func_diff_for_file "$oldbase" | func_apply_tmp_patch -p0 "$newbase"
+ func_taglist "$newfile"
+ elif test -f "$file"; then
func_taglist "$file"
fi >"$tagfile"
--
1.7.4.1.227.gadfe4
- [Bug-vc-dwim] [PATCH 0/3] let vc-chlog cope better with git add -i, Ralf Wildenhues, 2011/03/12
- [Bug-vc-dwim] [PATCH 1/3] vc-chlog: refactor tag list creation, for next change., Ralf Wildenhues, 2011/03/12
- [Bug-vc-dwim] [PATCH 2/3] New xfailing test: vc-chlog --stdin with dirty workdir., Ralf Wildenhues, 2011/03/12
- [Bug-vc-dwim] [PATCH 3a/3] vc-chlog: new option --dirty-workdir for git add --interactive., Ralf Wildenhues, 2011/03/12
- [Bug-vc-dwim] [PATCH 3b/3] vc-chlog --stdin: try to cope with dirty workdir.,
Ralf Wildenhues <=
- Re: [Bug-vc-dwim] [PATCH 0/3] let vc-chlog cope better with git add -i, Jim Meyering, 2011/03/16