From: Ramkumar Ramachandra <artagnon@gmail.com>
To: Git List <git@vger.kernel.org>
Cc: Jonathan Nieder <jrnieder@gmail.com>
Subject: [PATCH] fast-import: Create import-marks file when necessary
Date: Mon, 10 Jan 2011 01:03:57 +0530 [thread overview]
Message-ID: <1294601637-18416-1-git-send-email-artagnon@gmail.com> (raw)
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 reply other threads:[~2011-01-09 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-09 19:33 Ramkumar Ramachandra [this message]
2011-01-09 22:48 ` [PATCH] fast-import: Create import-marks file when necessary Junio C Hamano
2011-01-11 17:14 ` [PATCH] fast-import: Don't barf if import-marks file is missing Ramkumar Ramachandra
2011-01-11 17:51 ` Jonathan Nieder
2011-01-15 6:31 ` [PATCH] fast-import: Introduce --import-marks-if-exists Ramkumar Ramachandra
2011-01-11 20:05 ` [PATCH] fast-import: Don't barf if import-marks file is missing Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1294601637-18416-1-git-send-email-artagnon@gmail.com \
--to=artagnon@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).