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

feature suggestion: improve rerere

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Mar 6, 2013, 10:16 UTC
Message-ID
<20130306101640.GA15375@pengutronix.de>
Hello,

I think the following suggestion is sound. And it might even be easy to implement but I don't know how rerere works, so I might be wrong here.

When applying a patch it's normal to hit a conflict. For me this just happend:

	$ git diff
	diff --cc flash_otp_write.c
	index f360a3e,648e042..0000000
	--- a/flash_otp_write.c
	+++ b/flash_otp_write.c
	@@@ -15,8 -15,23 +15,29 @@@
	  
	  #include <mtd/mtd-user.h>
	  
	++<<<<<<< ours
	 +#include "common.h"
	 +
	++||||||| base
	++=======
	+ ssize_t xread(int fd, void *buf, size_t count)
	+ {
	+ 	ssize_t ret, done = 0;
	+ 
	+ retry:
	+ 	ret = read(fd, buf + done, count - done);
	+ 	if (ret < 0)
	+ 		return ret;
	+ 
	+ 	done += ret;
	+ 
	+ 	if (ret == 0 /* EOF */ || done == count)
	+ 		return done;
	+ 	else
	+ 		goto retry;
	+ }
	+ 
	++>>>>>>> theirs
	  int main(int argc,char *argv[])
	  {
		int fd, val, ret, size, wrote, len;
easy to resolve to:
	$ git diff
	diff --cc flash_otp_write.c
	index f360a3e,648e042..0000000
	--- a/flash_otp_write.c
	+++ b/flash_otp_write.c
	@@@ -15,8 -15,23 +15,25 @@@
	  
	  #include <mtd/mtd-user.h>
	  
	 +#include "common.h"
	 +
	+ ssize_t xread(int fd, void *buf, size_t count)
	+ {
	+ 	ssize_t ret, done = 0;
	+ 
	+ retry:
	+ 	ret = read(fd, buf + done, count - done);
	+ 	if (ret < 0)
	+ 		return ret;
	+ 
	+ 	done += ret;
	+ 
	+ 	if (ret == 0 /* EOF */ || done == count)
	+ 		return done;
	+ 	else
	+ 		goto retry;
	+ }
	+ 
	  int main(int argc,char *argv[])
	  {
		int fd, val, ret, size, wrote, len;

Now if I shuffle patches and put the new patch before the conflicting patch, I have to resolve first:

	$ git diff
	diff --cc flash_otp_write.c
	index d407ebb,31b963e..0000000
	--- a/flash_otp_write.c
	+++ b/flash_otp_write.c
	@@@ -15,6 -15,25 +15,31 @@@
	  
	  #include <mtd/mtd-user.h>
	  
	++<<<<<<< ours
	++||||||| base
	++#include "common.h"
	++
	++=======
	+ #include "common.h"
	+ 
	+ ssize_t xread(int fd, void *buf, size_t count)
	+ {
	+ 	ssize_t ret, done = 0;
	+ 
	+ retry:
	+ 	ret = read(fd, buf + done, count - done);
	+ 	if (ret < 0)
	+ 		return ret;
	+ 
	+ 	done += ret;
	+ 
	+ 	if (ret == 0 /* EOF */ || done == count)
	+ 		return done;
	+ 	else
	+ 		goto retry;
	+ }
	+ 
	++>>>>>>> theirs
	  int main(int argc,char *argv[])
	  {
		int fd, val, ret, size, wrote, len;

which is resolved to just adding the function and dropping the #include. But then readding the 2nd patch it conflicts again:

	$ git diff
	diff --cc flash_otp_write.c
	index 648e042,f360a3e..0000000
	--- a/flash_otp_write.c
	+++ b/flash_otp_write.c
	@@@ -15,23 -15,8 +15,29 @@@
	  
	  #include <mtd/mtd-user.h>
	  
	++<<<<<<< ours
	 +ssize_t xread(int fd, void *buf, size_t count)
	 +{
	 +	ssize_t ret, done = 0;
	 +
	 +retry:
	 +	ret = read(fd, buf + done, count - done);
	 +	if (ret < 0)
	 +		return ret;
	 +
	 +	done += ret;
	 +
	 +	if (ret == 0 /* EOF */ || done == count)
	 +		return done;
	 +	else
	 +		goto retry;
	 +}
	 +
	++||||||| base
	++=======
	+ #include "common.h"
	+ 
	++>>>>>>> theirs
	  int main(int argc,char *argv[])
	  {
		int fd, val, ret, size, wrote, len;

This is the same conflict as the first one, just with ours and theirs exchanged. So my suggestion is to make rerere use the resolution recorded for the first conflict here.

Sounds sensible?

Best regards Uwe

PS: I'm using Debian's git 1.8.2~rc2-1 and hope I didn't miss this
feature already implemented while looking through v1.8.2..junio/next.
-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Next: Johannes Sixt
Message 1 of 4 in “feature suggestion: improve rerere”
  1. Uwe Kleine-KönigMar 6, 2013
  2. Johannes SixtMar 6, 2013
  3. Uwe Kleine-KönigMar 6, 2013
  4. Johannes SixtMar 7, 2013

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.