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

[PATCH] fast-import: Create import-marks file when necessary

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jan 9, 2011, 19:33 UTC
Message-ID
<1294601637-18416-1-git-send-email-artagnon@gmail.com>

When both --import-marks and --export-marks are given, and specify the same file, that file should be created if it doesn't exist. Without this patch, the caller would have to check for the existence of a marks file and vary its fast-import invocation accordingly.

Requested-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
---
 fast-import.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/fast-import.c b/fast-import.c
index 5055504..cb7a9c9 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -3247,8 +3247,23 @@ static void parse_argv(void)
 		usage(fast_import_usage);
 
 	seen_data_command = 1;
-	if (import_marks_file)
+	if (import_marks_file) {
+		FILE *f = fopen(import_marks_file, "r");
+		if (!f) {
+			if (errno == ENOENT &&
+				!strcmp(import_marks_file, export_marks_file)) {
+				FILE *d = fopen(import_marks_file, "w");
+				if (!d)
+					die_errno("cannot create '%s'", import_marks_file);
+				fclose(d);
+			}
+			else
+				die_errno("cannot read '%s'", import_marks_file);
+		}
+		else
+			fclose(f);
 		read_marks();
+	}
 }
 
 int main(int argc, const char **argv)
-- 
1.7.4.rc1.8.g98938a.dirty
Next: Junio C Hamano
Message 1 of 6 in “fast-import: Create import-marks file when necessary”
  1. fast-import: Create import-marks file when necessaryRamkumar Ramachandra, Jan 9, 2011
  2. Junio C HamanoJan 9, 2011
  3. fast-import: Don't barf if import-marks file is missingRamkumar Ramachandra, Jan 11, 2011
  4. Jonathan NiederJan 11, 2011
  5. fast-import: Introduce --import-marks-if-existsRamkumar Ramachandra, Jan 15, 2011
  6. Junio C HamanoJan 11, 2011

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.