[PATCH] Fix calling parse_pathspec with no paths nor PATHSPEC_PREFER_* flags

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

 



When parse_pathspec() is called with no paths, the behavior could be
either return no paths, or return one path that is cwd. Some commands
do the former, some the latter. parse_pathspec() itself does not make
either the default and requires the caller to specify either flag if
it may run into this situation.

I've grep'd through all parse_pathspec() call sites. Some pass
neither, but those are guaranteed never pass empty path to
parse_pathspec(). There are two call sites that may pass empty path
and are fixed with this patch.

Reported-by: Antoine Pelisse <apelisse@xxxxxxxxx>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 line-log.c | 3 ++-
 revision.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/line-log.c b/line-log.c
index 8b6e497..717638b 100644
--- a/line-log.c
+++ b/line-log.c
@@ -760,7 +760,8 @@ void line_log_init(struct rev_info *rev, const char *prefix, struct string_list
 			r = r->next;
 		}
 		paths[count] = NULL;
-		parse_pathspec(&rev->diffopt.pathspec, 0, 0, "", paths);
+		parse_pathspec(&rev->diffopt.pathspec, 0,
+			       PATHSPEC_PREFER_FULL, "", paths);
 		free(paths);
 	}
 }
diff --git a/revision.c b/revision.c
index 0173e01..dd994e9 100644
--- a/revision.c
+++ b/revision.c
@@ -1372,7 +1372,8 @@ static void prepare_show_merge(struct rev_info *revs)
 			i++;
 	}
 	free_pathspec(&revs->prune_data);
-	parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC, 0, "", prune);
+	parse_pathspec(&revs->prune_data, PATHSPEC_ALL_MAGIC,
+		       PATHSPEC_PREFER_FULL, "", prune);
 	revs->limited = 1;
 }
 
-- 
1.8.2.83.gc99314b

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]