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

[PATCH 5/5] git-svn: don't allow commit if svn tree is not current

From
EWEric Wong <normalperson@yhbt.net>
Date
Jun 11, 2006, 07:03 UTC
Message-ID
<1150009432591-git-send-email-normalperson@yhbt.net>
In-Reply-To
<11500094313384-git-send-email-normalperson@yhbt.net>

If new revisions are fetched, that implies we haven't merged, acked, or nacked them yet, and attempting to write the tree we're committing means we'd silently clobber the newly fetched changes.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn.perl |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 8bc3d69..72129de 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -309,9 +309,16 @@ sub commit {
 	}
 	chomp @revs;
 
-	fetch();
-	chdir $SVN_WC or croak $!;
+	chdir $SVN_WC or croak "Unable to chdir $SVN_WC: $!\n";
 	my $info = svn_info('.');
+	my $fetched = fetch();
+	if ($info->{Revision} != $fetched->{revision}) {
+		print STDERR "There are new revisions that were fetched ",
+				"and need to be merged (or acknowledged) ",
+				"before committing.\n";
+		exit 1;
+	}
+	$info = svn_info('.');
 	read_uuid($info);
 	my $svn_current_rev =  $info->{'Last Changed Rev'};
 	foreach my $c (@revs) {
-- 
1.3.3.g2dc7b-dirty
Previous: Eric Wong
Message 6 of 6 in “git-svn: bug fixes (some resends)”
  1. git-svn: bug fixes (some resends)Eric Wong, Jun 11, 2006
  2. 1/5 git-svn: t0000: add -f flag to checkoutEric Wong, Jun 11, 2006
  3. 2/5 git-svn: fix handling of filenames with embedded '@'Eric Wong, Jun 11, 2006
  4. 3/5 git-svn: eol_cp corner-case fixesEric Wong, Jun 11, 2006
  5. 4/5 git-svn: restore original LC_ALL setting (or unset) for commitEric Wong, Jun 11, 2006
  6. 5/5 git-svn: don't allow commit if svn tree is not currentEric Wong, Jun 11, 2006

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.