Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


davidcole

6033 posts

Uber Geek

Trusted

#277335 8-Oct-2020 14:26
Send private message

I'm working on a script that will copy from a cloned git repository to an external folder.

 

I can get the files changed with

 

git diff --diff-filter=M --name-only /git/folder /e/folder

 

/git/folder has 1 file in it, a config file.

 

/e/folder has the config file and others (binaries etc).

 

What I want to know if if I can get if the /e/folder has something in it only.  If /git/folder has modifications then that's allowed as I'll copy that file over to top.  But I want to detected that a modification has been made to e/folder which is the dest, and stop the process so the user can sort it out.   I can't easily use the repository for holding the config and the binaries.

 

I'm trying to source control configuration files on servers to be able to track changes etc to them, and later automate their deployment.

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


Create new topic
  #2581362 8-Oct-2020 14:39
Send private message

If you want to check if the E folder's file contents is the same as a revision that already exists in the repository, you could use git show to get an older revision and compare the two.




davidcole

6033 posts

Uber Geek

Trusted

  #2581720 9-Oct-2020 07:15
Send private message

So git show, shows the files changed in the last commit?  But what if there's been multiple commits that haven't been applied to e?

 

This is why i assumed I needed diff, but I only care about a diff where teh result is a + or -, depending on the direction of the diff I can show just modifications, but you don't seem to be able to ignore all + or -...as then I'd be able to say, yes the e version has had a a modification so stop.....

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


marpada
475 posts

Ultimate Geek


  #2581795 9-Oct-2020 10:01
Send private message

Is /e/folder a regular folder or a git repository (remote)? If the former I don't think any git command will show you the difference between the two, but you can use the regular diff command to compare them or rsync to copy the changes back and forth.




davidcole

6033 posts

Uber Geek

Trusted

  #2581804 9-Oct-2020 10:24
Send private message

marpada:

 

Is /e/folder a regular folder or a git repository (remote)? If the former I don't think any git command will show you the difference between the two, but you can use the regular diff command to compare them or rsync to copy the changes back and forth.

 

 

/e/folder is reguler and git diff does seem to sucessfully comppare working copy to the regular folder.

 

So if theres a difference in the working copy it does:

 

--- a/Common/Apps/ArchiveMerge/config.xml
+++ b/E:/Apps/ArchiveMerge/config.xml
-<!-- change in git -->

 

And if the other way around

 

--- a/Common/Apps/ArchiveMerge/config.xml
+++ b/E:/Apps/ArchiveMerge/config.xml
+  <!-- change in working -->

 

But Ideally for my script to work, I'm happy for the -<!-- change in git --> to be ignored, as I'm about to sort that.....but if I see the  +  <!-- change in working --> I want to stop and alert the user.

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


davidcole

6033 posts

Uber Geek

Trusted

  #2581818 9-Oct-2020 10:56
Send private message

So this might be ridicuously hacky....but I think I can now Identify the b side changes:

 

git diff  --output-indicator-new=~ --diff-filter=M  Common/Apps/ /e/Apps/ | cut -c1 | grep -e \~

 

Changes the new indicator to ~ and then I go looking for that character which is a change on working copy side.

 

 





Previously known as psycik

Home Assistant: Gigabyte AMD A8 Brix, Home Assistant with Aeotech ZWave Controller, Raspberry PI, Wemos D1 Mini, Zwave, Shelly Humidity and Temperature sensors
Media:Chromecast v2, ATV4 4k, ATV4, HDHomeRun Dual
Server
Host Plex Server 3x3TB, 4x4TB using MergerFS, Samsung 850 evo 512 GB SSD, Proxmox Server with 1xW10, 2xUbuntu 22.04 LTS, Backblaze Backups, usenetprime.com fastmail.com Sharesies Trakt.TV Sharesight 


Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.