LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-04-2019, 02:10 AM   #1
TBotNik
Member
 
Registered: May 2016
Posts: 358

Rep: Reputation: Disabled
Git Merge-File


All,

Wrote this BASH script to merge multiple files into a new one in the git repository.

Code:
!# /bin/bash
################################################################################
# This Script will use git to merge file submitted via other scripts to			 #
# process all submitted files into the target file designated in the format	 #
# below.																								 #
################################################################################
# Format:																							 #
# 		Run with cmd:		bash git-merge.sh target-file source-file1.		 #
#																										 #
################################################################################

clear;
tfile=$1;							# Load the target file location, etc.
sfile=$2;							# load the mergin files array.  
fil_ray="";							# Clear the output var.
tdir=$(dirname "${tfile}")
if [ ! -d "$tdir" ]; then		# Create DIR is not existing
    echo "Making DIR ==> $tdir ";
    mkdir -p "$tdir";
    chown -R ndavis:users "$tdir" && chmod -R 775 "$tdir";
fi
if [ ! -f "$tfile" ]; then		# Create file is not existing
    touch "$tfile";
fi
echo "Merging files: ";
while IFS= read -r line		# Read in the Source file line by line.
do 
   echo "$line";
   fil_ray="$fil_ray -L ''$line'";
done < $sfile;
echo "Into Master file ==> $tfile! ";
# echo "File Line ==> $fil_ray";

git merge-file --union $tfile $fil_ray;
I've tried many way to run the "git merge-file" but always get errors:

Code:
Merging files: 
/home/files/Dropbox/ProJects (Case Conflict)/EM/em_objects.php
/home/files/Dropbox/ProJects (Case Conflict)/EM/em_objects.php.old
/home/files/Dropbox/ProJects (Case Conflict)/EM.old/em_objects.php
/home/files/Dropbox/ProJects (Case Conflict)/EM.old/em_objects.php.old
/home/files/Dropbox/ProJects/EM/em_objects.php
/home/files/Dropbox/Projects/EM/em_objects.php.old
/home/files/Dropbox/Projects/EM.old/em_objects.php
/home/files/Dropbox/Projects/EM.old/em_objects.php.old
/home/files/Dropbox/Projects/Web/External Projects/HTG/disDEP-WebSite/Frameworks/EnterpriseModules/em_objects.php
/home/files/Dropbox/backups/hosting-master-bup/davisoft-aec/public_html/EM/em_objects.php
/home/files/Dropbox/backups/hosting-master-bup/topicalchainreference/public_html/Frameworks/EnterpriseModules/em_objects.php
/home/files/Dropbox_old/ProJects/EM/em_objects.php
/home/files/Dropbox_old/ProJects/EM/em_objects.php.old
/home/files/Dropbox_old/ProJects/EM.old/em_objects.php
/home/files/Dropbox_old/ProJects/EM.old/em_objects.php.old
/home/files/Scripts/Dropbox/ProJects/EM/em_objects.php.old
/home/files/Scripts/Dropbox/ProJects/EM.old/em_objects.php
/home/files/Scripts/Dropbox/ProJects/EM.old/em_objects.php.old
Into Master file ==> /Syncs/ProJects/EM/em_objects.php! 
error: too many labels on the command line
usage: git merge-file [options] [-L name1 [-L orig [-L name2]]] file1 orig_file file2

    -p, --stdout          send results to standard output
    --diff3               use a diff3 based merge
    --ours                for conflicts, use our version
    --theirs              for conflicts, use their version
    --union               for conflicts, use a union version
    --marker-size <n>     for conflicts, use this marker size
    -q, --quiet           do not warn about conflicts
    -L <name>             set labels for file1/orig_file/file2
The source file was created with the command:

locate -i em_objects.php > /home/files/em_src.txt

I/m not that familiar with GIT and actually the first attempt at using "git merge-file". By all the online HOWTOs, I'm doing it right, but not sure why the errors.

All help appreciated!

Cheers!

TBNK
 
Old 12-04-2019, 02:13 AM   #2
TBotNik
Member
 
Registered: May 2016
Posts: 358

Original Poster
Rep: Reputation: Disabled
All,

OK first time I actually saw it saying "too many labels on the command line", so moving my git call into the while/do loop to nullify that. Will let you know if it works!

Cheers!

TBNK
 
Old 12-04-2019, 02:23 AM   #3
TBotNik
Member
 
Registered: May 2016
Posts: 358

Original Poster
Rep: Reputation: Disabled
all,

Now I just get the error set for each file in the source file;

Code:
usage: git merge-file [options] [-L name1 [-L orig [-L name2]]] file1 orig_file file2

    -p, --stdout          send results to standard output
    --diff3               use a diff3 based merge
    --ours                for conflicts, use our version
    --theirs              for conflicts, use their version
    --union               for conflicts, use a union version
    --marker-size <n>     for conflicts, use this marker size
    -q, --quiet           do not warn about conflicts
    -L <name>             set labels for file1/orig_file/file2
Cheers!

TBNK
 
Old 12-04-2019, 12:21 PM   #4
TBotNik
Member
 
Registered: May 2016
Posts: 358

Original Poster
Rep: Reputation: Disabled
All,

Do I need all the init and checkout cmds for git, before this process?

TBNK
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Gitpod git-bolts git-IDE onto GitHub for in-browser code git-editing LXer Syndicated Linux News 0 09-05-2018 05:50 AM
[SOLVED] Can't install Git repo (I don't git git ) Nemus Linux - Software 3 05-20-2011 03:09 PM
Merge many files in to one big file. like 20 file merge in one big file Jmor Linux - Newbie 2 10-29-2008 10:41 PM
LXer: KHTML Vs Webkit: To Merge or Not To Merge LXer Syndicated Linux News 0 10-27-2007 07:41 AM
convert and merge a fat32 to ext3 and then merge w/ another ext3? nkoplm Linux - General 3 03-23-2006 11:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration