git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] Revert part of 744dacd (builtin-mv: minimum fix to avoid losing files)

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 7, 2008, 10:54 UTC
Message-ID
<1204887286-32574-1-git-send-email-gitster@pobox.com>

When get_pathspec() was originally made absolute-path capable, we botched the interface to it, without dying inside the function when given a path that is outside the work tree, and made it the responsibility of callers to check the condition in a roundabout way. This is made unnecessary with the previous patch.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin-mv.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/builtin-mv.c b/builtin-mv.c
index 68aa2a6..94f6dd2 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -19,7 +19,6 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
 				  int count, int base_name)
 {
 	int i;
-	int len = prefix ? strlen(prefix) : 0;
 	const char **result = xmalloc((count + 1) * sizeof(const char *));
 	memcpy(result, pathspec, count * sizeof(const char *));
 	result[count] = NULL;
@@ -33,11 +32,8 @@ static const char **copy_pathspec(const char *prefix, const char **pathspec,
 			if (last_slash)
 				result[i] = last_slash + 1;
 		}
-		result[i] = prefix_path(prefix, len, result[i]);
-		if (!result[i])
-			exit(1); /* error already given */
 	}
-	return result;
+	return get_pathspec(prefix, result);
 }
 
 static void show_list(const char *label, struct path_list *list)
-- 
1.5.4.3.587.g0bdd73
Next: Junio C Hamano
Message 1 of 3 in “Revert part of 744dacd (builtin-mv: minimum fix to avoid losing files)”
  1. 2/4 Revert part of 744dacd (builtin-mv: minimum fix to avoid losing files)Junio C Hamano, Mar 7, 2008
  2. 3/4 Revert part of 1abf095 (git-add: adjust to the get_pathspec() changes)Junio C Hamano, Mar 7, 2008
  3. 4/4 Revert part of d089eba (setup: sanitize absolute and funny paths in get_pathspec())Junio C Hamano, Mar 7, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.