Commits

Yuya Nishihara committed 93f7c17

hg: don't always fail to read patches.queue file

Since 'status_filename' did not have enough space, read_first_line() never
succeeded. Even worse, the test case did not fail because patches/status and
patches-foo/status are the same.

Comments (0)

Files changed (2)

 static size_t get_mq_patchname(char* str, const char* nodeid, size_t n)
 {
     char buf[1024];
-    char status_filename[] = ".hg/patches/status";
+    char status_filename[512] = ".hg/patches/status";
     static const char QQ_STATUS_FILE_PAT[] = ".hg/patches-%s/status";
     static const size_t MAX_QQ_NAME = sizeof(status_filename)
         - (sizeof(QQ_STATUS_FILE_PAT) - 2 - 1);  // - "%s" - '\0'

tests/test-simple

     mkdir .hg/patches-foo
     printf 'a123456789abcdefghij\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' \
         > .hg/dirstate
-    echo '613132333435363738396162636465666768696a:baz.diff' >> .hg/patches-foo/status
+    echo '613132333435363738396162636465666768696a:qux.diff' >> .hg/patches-foo/status
     echo 'foo' > .hg/patches.queue  # named queue
-    assert_vcprompt "hg_mq applied named mq" "hg:613132333435[baz.diff]/foo" "%n:%r/%b"
+    assert_vcprompt "hg_mq applied named mq" "hg:613132333435[qux.diff]/foo" "%n:%r/%b"
 }
 
 test_simple_hg_revlog ()