bug-vc-dwim
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-vc-dwim] [PATCH] vc-chlog: correctly detect files removed in git tr


From: Ralf Wildenhues
Subject: [Bug-vc-dwim] [PATCH] vc-chlog: correctly detect files removed in git tree.
Date: Sat, 11 Jul 2009 10:28:00 +0200
User-agent: Mutt/1.5.20 (2009-06-15)

Hello Jim, all,

pushing this patch so that vc-chlog will not generate lines of the form

        * /dev/null:

when files have been removed, but instead will pick the name of the
removed file:

        * removed.c:

Cheers,
Ralf

    vc-chlog: correctly detect files removed in git tree.
    
    * vc-chlog.in (record_file): Record file name from the `^--- '
    line, use it in case the `^+++ ' line contains `/dev/null'.
    * tests/t-vc-chlog (run_vc_chlog): New test diff, from git,
    for a removed file.

diff --git a/tests/t-vc-chlog b/tests/t-vc-chlog
index 1497970..0b42f9c 100755
--- a/tests/t-vc-chlog
+++ b/tests/t-vc-chlog
@@ -637,4 +637,23 @@ test "$VERBOSE" != yes || { cat stdout; cat stderr >&2; }
 run_vc_chlog p11
 $diff_u expected stdout
 
+
+cat >p12 <<\EOF
+diff --git a/removed.c b/removed.c
+deleted file mode 100644
+index 587be6b..0000000
+--- a/removed.c
++++ /dev/null
+@@ -1 +0,0 @@
+-x
+EOF
+
+cat >expected <<\EOF
+       * removed.c:
+
+EOF
+
+run_vc_chlog p12
+$diff_u expected stdout
+
 Exit 0
diff --git a/vc-chlog.in b/vc-chlog.in
index 38e3b2b..063275a 100755
--- a/vc-chlog.in
+++ b/vc-chlog.in
@@ -192,6 +192,13 @@ func_extract_changed_lines ()
        file = "";
       }
     }
+    /^--- / {
+      if (!(1 in newhunk)) {   # do not match a removed line with 2 minuses at 
front
+       record_file();
+       maybe_file = $2;        # record possible name here, we might need it 
below
+       next;
+      }
+    }
     /^\+\+\+ / {
       if (!(1 in newhunk)) {   # do not match an added line with 2 pluses at 
front
        record_file();
@@ -200,6 +207,10 @@ func_extract_changed_lines ()
        # some vcs use single-character dir names (often a/ and b/) as diff
        # prefixes. strip them, and remember:
        hasprefix = sub("^./", "", file);
+       if (file == "/dev/null") {      # removed file
+         file = maybe_file;
+         hasprefix = sub("^./", "", file);
+       }
        next;
       }
     }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]