Re: [rebase PATCH] Introduce --merge-files (-M) flag

2019-05-06 Thread Achim Gratz
Michael Haubenwallner writes:
>> Your earlier suggestion of --record, the verb used in the comment quoted 
>> above
>> --update, or CV's suggestion --merge-files would make sense and be more
>> descriptive.

My reason for using a stronger word (even though enlist apparently calls
up the wron connotaions) is that once you've registered (enlisted,
enrolled) a library into the database, it'll stay there for all database
operations as long the file still exists.  There's an implicit contract
that the "registration" stays valid for the combined lifetime of the
file and the database.  Since you cannot (yet) choose a different
database, that requires a bit of coordination.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

DIY Stuff:
http://Synth.Stromeko.net/DIY.html


Re: [rebase PATCH] Introduce --merge-files (-M) flag (WAS: Introduce --no-rebase flag)

2019-05-06 Thread Michael Haubenwallner

On 5/4/19 4:33 PM, Brian Inglis wrote:
> On 2019-05-03 09:32, Michael Haubenwallner wrote:
>> On 4/12/19 8:03 PM, Corinna Vinschen wrote:
>>> On Apr 12 15:52, Michael Haubenwallner wrote:
 The --no-rebase flag is to update the database for new files, without
>>> Wouldn't something like --merge-files be more descriptive?
>> What about --recognize ?
> 
> "The --recognize flag is to update the database for new files, without
> performing a rebase.  The file names provided should have been rebased
> using the --oblivious flag just before."
> 
> Recognize does not mean record or update in English but see, identify, or
> acknowledge.
> 
> Your earlier suggestion of --record, the verb used in the comment quoted above
> --update, or CV's suggestion --merge-files would make sense and be more
> descriptive.

On a first thought, "merge files" does have a different meaning in the Gentoo
context already, as in "merge files from staging directory into the live file
system".
However, on a second thought, "rebase --merge-files" is performed afterwards,
but still part of that "merge files" phase, so the name does actually fit.

Patch updated.

> I use such brief comments or descriptions as a guide to pick the most obvious
> names for functions, options, etc: if the comment or description then reads as
> if redundant, the choice is good.

Agreed, thanks!  (had --update or even --update-db in mind as well)
/haubi/
>From 09ddd358a1d829470636158375fe606e6d2e506b Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner 
Date: Fri, 12 Apr 2019 10:26:46 +0200
Subject: [PATCH] Introduce --merge-files (-M) flag.

The --merge-files flag is to update the database for new files, without
performing a rebase.  The file names provided should have been rebased
using the --oblivious flag just before.
---
 rebase.c | 48 +++-
 1 file changed, 35 insertions(+), 13 deletions(-)

diff --git a/rebase.c b/rebase.c
index 56537d6..a403c85 100644
--- a/rebase.c
+++ b/rebase.c
@@ -72,6 +72,7 @@ BOOL down_flag = FALSE;
 BOOL image_info_flag = FALSE;
 BOOL image_storage_flag = FALSE;
 BOOL image_oblivious_flag = FALSE;
+BOOL perform_rebase_flag = TRUE;
 BOOL force_rebase_flag = FALSE;
 ULONG offset = 0;
 int args_index = 0;
@@ -533,9 +534,9 @@ load_image_info ()
   {
 	img_info_list[i].name = NULL;
 	/* Ensure that existing database entries are not touched when
-	 *  --oblivious is active, even if they are out-of sync with
-	 *  reality. */
-	if (image_oblivious_flag)
+	 *  --oblivious or --merge-files is active, even if they are
+	 *  out-of sync with reality. */
+	if (image_oblivious_flag || !perform_rebase_flag)
 	  img_info_list[i].flag.cannot_rebase = 2;
   }
   /* Eventually read the strings. */
@@ -584,8 +585,8 @@ load_image_info ()
 static BOOL
 set_cannot_rebase (img_info_t *img)
 {
-  /* While --oblivious is active, cannot_rebase is set to 2 on loading
-   * the database entries */
+  /* While --oblivious or --merge-files is active, cannot_rebase
+   * is set to 2 on loading the database entries */
   if (img->flag.cannot_rebase <= 1 )
 {
   int fd = open (img->name, O_WRONLY);
@@ -878,7 +879,7 @@ collect_image_info (const char *pathname)
 
   /* Skip if not rebaseable, but only if we're collecting for rebasing,
  not if we're collecting for printing only. */
-  if (!image_info_flag && !is_rebaseable (pathname))
+  if (perform_rebase_flag && !is_rebaseable (pathname))
 {
   if (!quiet)
 	fprintf (stderr, "%s: skipped because not rebaseable\n", pathname);
@@ -928,8 +929,16 @@ collect_image_info (const char *pathname)
 }
   img_info_list[img_info_size].slot_size
 = roundup2 (img_info_list[img_info_size].size, ALLOCATION_SLOT);
-  img_info_list[img_info_size].flag.needs_rebasing = 1;
-  img_info_list[img_info_size].flag.cannot_rebase = 0;
+  if (perform_rebase_flag)
+{
+  img_info_list[img_info_size].flag.needs_rebasing = 1;
+  img_info_list[img_info_size].flag.cannot_rebase = 0;
+}
+  else
+{
+  img_info_list[img_info_size].flag.needs_rebasing = 0;
+  img_info_list[img_info_size].flag.cannot_rebase = 2;
+}
   /* This back and forth from POSIX to Win32 is a way to get a full path
  more thoroughly.  For instance, the difference between /bin and
  /usr/bin will be eliminated. */
@@ -970,7 +979,9 @@ collect_image_info (const char *pathname)
   }
 #endif
   if (verbose)
-fprintf (stderr, "rebasing %s because filename given on command line\n", img_info_list[img_info_size].name);
+fprintf (stderr, "%s %s because filename given on command line\n",
+	 perform_rebase_flag ? "rebasing" : "considering",
+	 img_info_list[img_info_size].name);
   ++img_info_size;
   return TRUE;
 }
@@ -1170,6 +1181,7 @@ static struct option long_options[] = {
   {"help",	no_argument,	   NULL, 'h'},
   {"usage",	no_argument,	   NULL, 'h'},
   {"info",	no_argument,	   NULL, 'i'},
+  {"merge-files",no_argument,	   NULL, 'M'},
   {"offset",	re